import request from '@/utils/request'

const API_NAME = '/bms/borrows'

export default {
  // 获取所有借阅
  queryAll() {
    return request({
      url: `${API_NAME}/`,
      method: 'get'
    })
  },
  // 分页获取所有借阅
  queryByPage(page, limit, searchObj) {
    return request({
      url: `${API_NAME}/${page}/${limit}`,
      method: 'get',
      params: searchObj
    })
  },
  // 分页获取未还图书
  queryReturnByPage(page, limit, searchObj) {
    return request({
      url: `${API_NAME}/return/${page}/${limit}`,
      method: 'get',
      params: searchObj
    })
  },
  // 修改一个借阅(还书)
  update(borrow) {
    return request({
      url: `${API_NAME}/`,
      method: 'put',
      data: borrow
    })
  },
  // 新增一个借阅(借书)
  insert(borrow) {
    return request({
      url: `${API_NAME}/`,
      method: 'post',
      data: borrow
    })
  },
  // 根据ID获取一个借阅
  queryById(id) {
    return request({
      url: `${API_NAME}/${id}`,
      method: 'get'
    })
  }

}
